<?php

namespace App\Admin\Controllers;

use App\Models\Tool\Oil;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class OilController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'Oil';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Oil());

        $grid->column('id', __('Id'));
        $grid->column('uid', __('Uid'));
        $grid->column('date', __('Date'));
        $grid->column('total_price', __('Total price'));
        $grid->column('unit_price', __('Unit price'));
        $grid->column('model_type', __('Model type'));
        $grid->column('liter', __('Liter'));
        $grid->column('mileage', __('Mileage'));
        $grid->column('image_url', __('Image url'));
        $grid->column('address', __('Address'));
        $grid->column('station_addr', __('Station addr'));
        $grid->column('source', __('Source'));
        $grid->column('state', __('State'));
        $grid->column('is_del', __('Is del'));
        $grid->column('create_time', __('Create time'));
        $grid->column('update_time', __('Update time'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(Oil::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('uid', __('Uid'));
        $show->field('date', __('Date'));
        $show->field('total_price', __('Total price'));
        $show->field('unit_price', __('Unit price'));
        $show->field('model_type', __('Model type'));
        $show->field('liter', __('Liter'));
        $show->field('mileage', __('Mileage'));
        $show->field('image_url', __('Image url'));
        $show->field('address', __('Address'));
        $show->field('station_addr', __('Station addr'));
        $show->field('source', __('Source'));
        $show->field('state', __('State'));
        $show->field('is_del', __('Is del'));
        $show->field('create_time', __('Create time'));
        $show->field('update_time', __('Update time'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Oil());

        $form->number('uid', __('Uid'));
        $form->text('date', __('Date'));
        $form->decimal('total_price', __('Total price'))->default(0.00);
        $form->decimal('unit_price', __('Unit price'))->default(0.00);
        $form->text('model_type', __('Model type'));
        $form->decimal('liter', __('Liter'))->default(0.00);
        $form->number('mileage', __('Mileage'));
        $form->text('image_url', __('Image url'));
        $form->text('address', __('Address'));
        $form->text('station_addr', __('Station addr'));
        $form->switch('source', __('Source'))->default(1);
        $form->switch('state', __('State'))->default(1);
        $form->switch('is_del', __('Is del'));
        $form->datetime('create_time', __('Create time'))->default(date('Y-m-d H:i:s'));
        $form->datetime('update_time', __('Update time'))->default(date('Y-m-d H:i:s'));

        return $form;
    }
}
